using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace spaceInvaders
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class GUI : Microsoft.Xna.Framework.DrawableGameComponent
    {

        private int vidas;

        public int Vidas
        {
            get { return vidas; }
            set { vidas = value; }
        }
        private int puntuacion;

        public int Puntuacion
        {
            get { return puntuacion; }
            set { puntuacion = value; }
        }

        private int nivel;

        public int Nivel
        {
            get { return nivel; }
            set { nivel = value; }
        }

        SpriteBatch spriteBatch;
        SpriteFont fuente;
        SpriteFont numeros;
        Texture2D vidaNave;
        Vector2 posVidas; 

        public GUI(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            posVidas = new Vector2(170, 565);
            vidas = 3;
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            fuente = Game.Content.Load<SpriteFont>("texto");
            numeros = Game.Content.Load<SpriteFont>("numeros");
            vidaNave = Game.Content.Load<Texture2D>("ship2");
            base.LoadContent();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            Vector2 pos = new Vector2(posVidas.X, posVidas.Y);
            for (int i = 0; i < vidas;i++ )
            {
                spriteBatch.Draw(vidaNave, pos, Color.Red);
                pos.X += 45f;
              
            }

            spriteBatch.DrawString(fuente, "puntuacion:", new Vector2(0, 0), Color.Green);

            spriteBatch.DrawString(numeros,puntuacion.ToString(), new Vector2(320, 0), Color.Green);

            spriteBatch.DrawString(fuente, "nivel:", new Vector2(500, 0), Color.Green);

            spriteBatch.DrawString(numeros, (nivel+1).ToString(), new Vector2(700, 0), Color.Green);


            spriteBatch.DrawString(fuente, "VIDAS:\n", new Vector2(10, 560), Color.Red);

            spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}